from openpyxl import load_workbook


class OperatorExcel:

    def __init__(self, case_path=None):
        if case_path:
            self.case_path = case_path
        else:
            case_path = '../data/template_testcase.xlsx'
        self.api_case = load_workbook(case_path)['api']
        self.scene_case = load_workbook(case_path)['scene']

    # 获取所有用例
    def get_all_case(self):
        case_data = []
        for row in range(1, self.api_case.max_row+1):
            case = []
            for column in range(1, self.api_case.max_column+1):
                case.append(self.api_case.cell(row=row, column=column).value)
            case_data.append(case)
        return case_data

    def get_scene_case(self):
        case_data = []
        for row in range(1, self.scene_case.max_row + 1):
            case = []
            for column in range(1, self.scene_case.max_column + 1):
                case.append(self.scene_case.cell(row=row, column=column).value)
            case_data.append(case)
        return case_data


if __name__ == '__main__':
    # print(OperatorExcel().get_all_case())
    print(OperatorExcel().get_scene_case())